home *** CD-ROM | disk | FTP | other *** search
/ Champak 141 / (Vol 141) Oct 17 2011.iso / Games / gamma-bros.swf / scripts / __Packages / classes / enemy / DroidD.as < prev    next >
Encoding:
Text File  |  2011-10-17  |  5.9 KB  |  221 lines

  1. class classes.enemy.DroidD
  2. {
  3.    var x;
  4.    var y;
  5.    var moveScript;
  6.    var id;
  7.    var clip;
  8.    var f2;
  9.    var dir;
  10.    var axis;
  11.    var xDest;
  12.    var yDest;
  13.    var oldDir;
  14.    var xMov = 0;
  15.    var yMov = 0;
  16.    var xMovT = 0;
  17.    var yMovT = 0;
  18.    var speedOrig = 8;
  19.    var speed = 8;
  20.    var xDestMet = false;
  21.    var yDestMet = false;
  22.    var c = 0;
  23.    var feelerInfo = [[-400,0,400,40],[0,0,400,40],[0,-400,40,400],[0,0,40,400]];
  24.    var dirArray = ["L","R","U","D"];
  25.    var power = 20;
  26.    var Name = "droidD";
  27.    function DroidD(px, py, pmoveScript, pid)
  28.    {
  29.       this.x = px;
  30.       this.y = py;
  31.       this.moveScript = pmoveScript.slice();
  32.       this.id = pid;
  33.       _root.d = _root.d + 1;
  34.       this.clip = _root.attachMovie("droidA","droidD" + this.id + "Clip",_root.d + 50000);
  35.       this.clip._x = this.x;
  36.       this.clip._y = this.y;
  37.       this.speed *= _root.dif.speed;
  38.       this.speedOrig = this.speed;
  39.       this.speedVar();
  40.       var _loc3_ = new flash.geom.Transform(this.clip);
  41.       var _loc4_ = new flash.geom.ColorTransform(0,0,0,1,-255,-255,-255,0);
  42.       _loc3_.colorTransform = _loc4_;
  43.       this.parseMoveScript();
  44.       _root.stats.created = _root.stats.created + 1;
  45.    }
  46.    function speedVar()
  47.    {
  48.       if(random(3) == 1)
  49.       {
  50.          this.speed *= _root.randRange2(0.9999,1.0001);
  51.       }
  52.    }
  53.    function bombed(num)
  54.    {
  55.       this.f2 = "death";
  56.    }
  57.    function parseMoveScript()
  58.    {
  59.       this.dir = this.moveScript[0];
  60.       if(this.dir == "break")
  61.       {
  62.          delete this.moveScript;
  63.          this[this.axis + "MovT"] = 0;
  64.          this.f2 = "wander";
  65.          this.axis = random(10) <= 4 ? "y" : "x";
  66.          this[this.axis + "MovT"] = random(2) <= 0 ? -1 * this.speed : this.speed;
  67.          this.speedVar();
  68.          this.getDirString();
  69.       }
  70.       else
  71.       {
  72.          this[this.axis + "MovT"] = 0;
  73.          this.f2 = "gotoXYDest";
  74.          this.axis = !(this.dir == "L" || this.dir == "R") ? "y" : "x";
  75.          this[this.axis + "MovT"] = !(this.dir == "L" || this.dir == "U") ? this.speed : -1 * this.speed;
  76.          this.speedVar();
  77.          if(this.dir == "L" || this.dir == "U")
  78.          {
  79.             this[this.axis + "Dest"] = this[this.axis] - this.moveScript[1];
  80.          }
  81.          else
  82.          {
  83.             this[this.axis + "Dest"] = this[this.axis] + this.moveScript[1];
  84.          }
  85.          this.moveScript.splice(0,2);
  86.       }
  87.    }
  88.    function gotoXYDest()
  89.    {
  90.       if(Math.abs(this[this.axis + "Dest"] - this[this.axis]) < this.speed + 1)
  91.       {
  92.          if(this.axis == "x")
  93.          {
  94.             this.x = this.xDest;
  95.          }
  96.          else
  97.          {
  98.             this.y = this.yDest;
  99.          }
  100.          this.parseMoveScript();
  101.       }
  102.    }
  103.    function getDirString()
  104.    {
  105.       if(this.xMovT < -1)
  106.       {
  107.          this.dir = "L";
  108.       }
  109.       else if(this.xMovT > 1)
  110.       {
  111.          this.dir = "R";
  112.       }
  113.       else if(this.yMovT > 1)
  114.       {
  115.          this.dir = "D";
  116.       }
  117.       else if(this.yMovT < -1)
  118.       {
  119.          this.dir = "U";
  120.       }
  121.    }
  122.    function attacking()
  123.    {
  124.    }
  125.    function death()
  126.    {
  127.       _root.stats.destroyed = _root.stats.destroyed + 1;
  128.       _root.stats.score += 100;
  129.       _root.powerUpB(this.x,this.y,80,"doubleLaserA",2);
  130.       _root.createExploD([this.x + this.clip._width / 2,this.y + this.clip._height / 2,_root.randRange(80,130),_root.randRange(75,100)]);
  131.       var _loc3_ = 0;
  132.       var _loc4_ = random(3);
  133.       while(_loc3_ < _loc4_)
  134.       {
  135.          _root.createShrapnel([this.x + this.clip._width / 2,this.y + this.clip._height / 2,"droidA","",false,true]);
  136.          _loc3_ = _loc3_ + 1;
  137.       }
  138.       _root.audio.playLevel4("droidX" + (random(3) + 1),_root.randRange(16,35));
  139.       _root.removeChar("droidD" + this.id);
  140.       this.f2 = "";
  141.    }
  142.    function wander()
  143.    {
  144.       if(random(100) > 96 + _root.dif.wander)
  145.       {
  146.          this[this.axis + "MovT"] = 0;
  147.          this.axis = this.axis != "x" ? "x" : "y";
  148.          this[this.axis + "MovT"] = random(2) <= 0 ? -1 * this.speed : this.speed;
  149.          this.getDirString();
  150.       }
  151.    }
  152.    function death2()
  153.    {
  154.       _root.removeChar("droidD" + this.id);
  155.       this.f2 = "";
  156.    }
  157.    function main()
  158.    {
  159.       this[this.f2]();
  160.       if(this.oldDir != this.dir)
  161.       {
  162.          this.clip.gotoAndStop("fly" + this.dir);
  163.       }
  164.       this.oldDir = this.dir;
  165.       var _loc4_ = 0;
  166.       var _loc6_ = _root.broShots.length;
  167.       while(_loc4_ < _loc6_)
  168.       {
  169.          var _loc5_ = _root.broShots[_loc4_] + "Clip";
  170.          if(this.clip.hitTest(_root[_loc5_]))
  171.          {
  172.             this.f2 = "death";
  173.             _root[_root.char].fc = _root[_root.char].fireFreq - _root.rapidVar;
  174.             var _loc3_ = _root.broShots[_loc4_];
  175.             _root[_loc3_].exploX = this.x + this.clip._width / 2;
  176.             _root[_loc3_].exploY = this.y + this.clip._height / 2;
  177.             _root[_loc3_].hit(1);
  178.             break;
  179.          }
  180.          _loc4_ = _loc4_ + 1;
  181.       }
  182.       if(this.clip.hitTest(_root[_root.char + "Clip"]))
  183.       {
  184.          _root[_root.char].hit(this.xMov,this.yMov,100,this.power);
  185.          this.f2 = "death";
  186.       }
  187.       if(this.x > 1050 || this.x < -50 || this.y < -50 || this.y > 650)
  188.       {
  189.          this.f2 = "death2";
  190.       }
  191.       if(this.xMovT < this.xMov)
  192.       {
  193.          this.xMov -= 1;
  194.       }
  195.       else if(this.xMovT > this.xMov)
  196.       {
  197.          this.xMov += 1;
  198.       }
  199.       else
  200.       {
  201.          this.xMov = this.xMovT;
  202.       }
  203.       if(this.yMovT < this.yMov)
  204.       {
  205.          this.yMov -= 1;
  206.       }
  207.       else if(this.yMovT > this.yMov)
  208.       {
  209.          this.yMov += 1;
  210.       }
  211.       else
  212.       {
  213.          this.yMov = this.yMovT;
  214.       }
  215.       this.x += this.xMov;
  216.       this.y += this.yMov;
  217.       this.clip._x = this.x;
  218.       this.clip._y = this.y;
  219.    }
  220. }
  221.